/*   1:    */ package tt.dz.web.controller.user;
/*   2:    */ 
/*   3:    */ import com.alibaba.fastjson.JSON;
/*   4:    */ import com.alibaba.fastjson.JSONObject;
/*   5:    */ import java.util.ArrayList;
/*   6:    */ import java.util.HashMap;
/*   7:    */ import java.util.List;
/*   8:    */ import java.util.Map;
/*   9:    */ import javax.annotation.Resource;
/*  10:    */ import javax.servlet.http.HttpServletRequest;
/*  11:    */ import javax.servlet.http.HttpServletResponse;
/*  12:    */ import org.apache.commons.collections.CollectionUtils;
/*  13:    */ import org.apache.commons.lang.StringUtils;
/*  14:    */ import org.springframework.stereotype.Controller;
/*  15:    */ import org.springframework.web.bind.annotation.RequestMapping;
/*  16:    */ import org.springframework.web.bind.annotation.RequestParam;
/*  17:    */ import org.springframework.web.bind.annotation.ResponseBody;
/*  18:    */ import tt.dz.biz.service.rpc.RPCMsVerifyCodeService;
/*  19:    */ import tt.dz.biz.service.user.OperListService;
/*  20:    */ import tt.dz.common.DzDigester;
/*  21:    */ import tt.dz.common.LogUtil;
/*  22:    */ import tt.dz.vo.OperListVO;
/*  23:    */ import tt.dz.vo.ResponseModle;
/*  24:    */ import tt.dz.web.controller.BaseController;
/*  25:    */ 
/*  26:    */ @Controller
/*  27:    */ public class OperListController
/*  28:    */   extends BaseController
/*  29:    */ {
/*  30:    */   @Resource(name="operListService")
/*  31:    */   private OperListService operListService;
/*  32:    */   @Resource(name="rpcMsVerifyCodeService")
/*  33:    */   private RPCMsVerifyCodeService rpcMsVerifyCodeService;
/*  34:    */   
/*  35:    */   @RequestMapping(value={"/listAllOperList"}, produces={"application/json;charset=UTF-8"})
/*  36:    */   @ResponseBody
/*  37:    */   public String listAllOperList()
/*  38:    */   {
/*  39: 48 */     ResponseModle responseModle = null;
/*  40:    */     try
/*  41:    */     {
/*  42: 50 */       List<OperListVO> operListList = this.operListService.listAllOperList();
/*  43: 51 */       responseModle = new ResponseModle("success", operListList);
/*  44:    */     }
/*  45:    */     catch (Exception e)
/*  46:    */     {
/*  47: 53 */       LogUtil.error("查询操作员异常", e);
/*  48: 54 */       responseModle = new ResponseModle("error", new ArrayList());
/*  49:    */     }
/*  50: 56 */     return JSON.toJSONString(responseModle);
/*  51:    */   }
/*  52:    */   
/*  53:    */   @RequestMapping(value={"/queryOperList"}, produces={"application/json;charset=UTF-8"})
/*  54:    */   @ResponseBody
/*  55:    */   public String queryOperList(HttpServletRequest request)
/*  56:    */   {
/*  57: 67 */     ResponseModle responseModle = null;
/*  58:    */     try
/*  59:    */     {
/*  60: 69 */       OperListVO operListVO = (OperListVO)JSON.parseObject(request.getParameter("operListVO"), OperListVO.class);
/*  61: 70 */       List<OperListVO> operListList = this.operListService.queryOperList(operListVO);
/*  62: 71 */       responseModle = new ResponseModle("success", operListList);
/*  63:    */     }
/*  64:    */     catch (Exception e)
/*  65:    */     {
/*  66: 73 */       LogUtil.error("根据传入条件查询操作员异常", e);
/*  67: 74 */       responseModle = new ResponseModle("error", new ArrayList());
/*  68:    */     }
/*  69: 76 */     return JSON.toJSONString(responseModle);
/*  70:    */   }
/*  71:    */   
/*  72:    */   @RequestMapping(value={"/modifyOperList"}, produces={"application/json;charset=UTF-8"})
/*  73:    */   @ResponseBody
/*  74:    */   public String modifyOperList(HttpServletRequest request, HttpServletResponse response)
/*  75:    */   {
/*  76: 88 */     boolean excuteFlag = false;
/*  77:    */     try
/*  78:    */     {
/*  79: 90 */       String modifyType = request.getParameter("modifyType");
/*  80: 91 */       OperListVO operListVO = (OperListVO)JSON.parseObject(request.getParameter("operListVO"), OperListVO.class);
/*  81: 92 */       List<OperListVO> existOperList = null;
/*  82: 93 */       if ((StringUtils.isBlank(operListVO.getMobileNo())) && 
/*  83: 94 */         (StringUtils.isBlank(operListVO.getNickName())) && 
/*  84: 95 */         (StringUtils.isBlank(operListVO.getEmail()))) {
/*  85: 96 */         return JSON.toJSONString(assemblyResponseData(false, "手机号码、昵称和邮件至少一个不能为空。"));
/*  86:    */       }
/*  87: 98 */       if ("insert".equals(modifyType))
/*  88:    */       {
/*  89: 99 */         if (StringUtils.isNotBlank(operListVO.getMobileNo()))
/*  90:    */         {
/*  91:100 */           OperListVO param = new OperListVO();
/*  92:101 */           param.setMobileNo(operListVO.getMobileNo());
/*  93:102 */           existOperList = this.operListService.queryOperListNotLike(param);
/*  94:103 */           if (CollectionUtils.isNotEmpty(existOperList)) {
/*  95:104 */             return JSON.toJSONString(assemblyResponseData(false, "存在相同手机号码的操作员，请确认后再试。"));
/*  96:    */           }
/*  97:    */         }
/*  98:107 */         if (StringUtils.isNotBlank(operListVO.getNickName()))
/*  99:    */         {
/* 100:108 */           OperListVO param = new OperListVO();
/* 101:109 */           param.setNickName(operListVO.getNickName());
/* 102:110 */           existOperList = this.operListService.queryOperListNotLike(param);
/* 103:111 */           if (CollectionUtils.isNotEmpty(existOperList)) {
/* 104:112 */             return JSON.toJSONString(assemblyResponseData(false, "存在相同昵称的操作员，请确认后再试。"));
/* 105:    */           }
/* 106:    */         }
/* 107:115 */         if (StringUtils.isNotBlank(operListVO.getEmail()))
/* 108:    */         {
/* 109:116 */           OperListVO param = new OperListVO();
/* 110:117 */           param.setEmail(operListVO.getEmail());
/* 111:118 */           existOperList = this.operListService.queryOperListNotLike(param);
/* 112:119 */           if (CollectionUtils.isNotEmpty(existOperList)) {
/* 113:120 */             return JSON.toJSONString(assemblyResponseData(false, "存在有相同邮件的操作员，请确认后再试。"));
/* 114:    */           }
/* 115:    */         }
/* 116:123 */         excuteFlag = this.operListService.insertOperList(operListVO);
/* 117:    */       }
/* 118:125 */       else if ("update".equals(modifyType))
/* 119:    */       {
/* 120:127 */         if (StringUtils.isNotBlank(operListVO.getMobileNo()))
/* 121:    */         {
/* 122:128 */           OperListVO param = new OperListVO();
/* 123:129 */           param.setMobileNo(operListVO.getMobileNo());
/* 124:130 */           existOperList = this.operListService.queryOperListNotLike(param);
/* 125:131 */           if (CollectionUtils.isNotEmpty(existOperList)) {
/* 126:132 */             for (OperListVO tmp : existOperList) {
/* 127:133 */               if (!tmp.getManagerId().equals(operListVO.getManagerId())) {
/* 128:134 */                 return JSON.toJSONString(assemblyResponseData(false, "存在相同手机号码的操作员，请确认后再试。"));
/* 129:    */               }
/* 130:    */             }
/* 131:    */           }
/* 132:    */         }
/* 133:139 */         if (StringUtils.isNotBlank(operListVO.getNickName()))
/* 134:    */         {
/* 135:140 */           OperListVO param = new OperListVO();
/* 136:141 */           param.setNickName(operListVO.getNickName());
/* 137:142 */           existOperList = this.operListService.queryOperListNotLike(param);
/* 138:143 */           if (CollectionUtils.isNotEmpty(existOperList)) {
/* 139:144 */             for (OperListVO tmp : existOperList) {
/* 140:145 */               if (!tmp.getManagerId().equals(operListVO.getManagerId())) {
/* 141:146 */                 return JSON.toJSONString(assemblyResponseData(false, "存在相同昵称的操作员，请确认后再试。"));
/* 142:    */               }
/* 143:    */             }
/* 144:    */           }
/* 145:    */         }
/* 146:151 */         if (StringUtils.isNotBlank(operListVO.getEmail()))
/* 147:    */         {
/* 148:152 */           OperListVO param = new OperListVO();
/* 149:153 */           param.setEmail(operListVO.getEmail());
/* 150:154 */           existOperList = this.operListService.queryOperListNotLike(param);
/* 151:155 */           if (CollectionUtils.isNotEmpty(existOperList)) {
/* 152:156 */             for (OperListVO tmp : existOperList) {
/* 153:157 */               if (!tmp.getManagerId().equals(operListVO.getManagerId())) {
/* 154:158 */                 return JSON.toJSONString(assemblyResponseData(false, "存在有相同邮件的操作员，请确认后再试。"));
/* 155:    */               }
/* 156:    */             }
/* 157:    */           }
/* 158:    */         }
/* 159:163 */         excuteFlag = this.operListService.updateOperList(operListVO);
/* 160:    */       }
/* 161:    */     }
/* 162:    */     catch (Exception e)
/* 163:    */     {
/* 164:166 */       LogUtil.error("更改操作员异常", e);
/* 165:167 */       return JSON.toJSONString(assemblyResponseData(false, "系统异常，请稍后再试。"));
/* 166:    */     }
/* 167:169 */     return JSON.toJSONString(assemblyResponseData(excuteFlag, null));
/* 168:    */   }
/* 169:    */   
/* 170:    */   @RequestMapping(value={"/modifyOperPassword"}, produces={"application/json;charset=UTF-8"})
/* 171:    */   @ResponseBody
/* 172:    */   public String modifyOperPassword(HttpServletRequest request)
/* 173:    */   {
/* 174:180 */     boolean excuteFlag = false;
/* 175:181 */     Map<String, String> msgMap = new HashMap();
/* 176:    */     try
/* 177:    */     {
/* 178:183 */       String password = request.getParameter("password");
/* 179:184 */       String newPassword = request.getParameter("newPassword");
/* 180:185 */       String repeatPassword = request.getParameter("repeatPassword");
/* 181:186 */       if ((StringUtils.isBlank(password)) || (StringUtils.isBlank(newPassword)) || 
/* 182:187 */         (StringUtils.isBlank(repeatPassword)))
/* 183:    */       {
/* 184:188 */         msgMap.put("errorMsg", "请输入完整的修改信息！");
/* 185:189 */         return JSON.toJSONString(assemblyResponseData(excuteFlag, msgMap));
/* 186:    */       }
/* 187:191 */       if (!newPassword.equals(repeatPassword))
/* 188:    */       {
/* 189:192 */         msgMap.put("errorMsg", "请确认新密码于重复密码一致！");
/* 190:193 */         return JSON.toJSONString(assemblyResponseData(excuteFlag, msgMap));
/* 191:    */       }
/* 192:195 */       OperListVO operListVO = new OperListVO();
/* 193:196 */       operListVO.setPassword(DzDigester.sha1ForOper(password));
/* 194:197 */       OperListVO oldOper = this.operListService.validateOper(operListVO);
/* 195:198 */       if (oldOper != null)
/* 196:    */       {
/* 197:199 */         oldOper.setPassword(DzDigester.sha1ForOper(newPassword));
/* 198:200 */         excuteFlag = this.operListService.updateOperList(oldOper);
/* 199:    */       }
/* 200:    */       else
/* 201:    */       {
/* 202:202 */         msgMap.put("errorMsg", "当前密码输入错误。");
/* 203:    */       }
/* 204:    */     }
/* 205:    */     catch (Exception e)
/* 206:    */     {
/* 207:205 */       LogUtil.error("更改操作员异常", e);
/* 208:206 */       msgMap.put("errorMag", "更改操作员密码出现了异常！请稍后再试");
/* 209:    */     }
/* 210:208 */     return JSON.toJSONString(assemblyResponseData(excuteFlag, msgMap));
/* 211:    */   }
/* 212:    */   
/* 213:    */   @RequestMapping(value={"/sendModifyPasswordVerifyCode"}, produces={"application/json;charset=UTF-8"})
/* 214:    */   @ResponseBody
/* 215:    */   public String sendModifyPasswordVerifyCode(@RequestParam("moboleNo") String moboleNo)
/* 216:    */   {
/* 217:219 */     ResponseModle responseModle = new ResponseModle("success", null);
/* 218:220 */     OperListVO oper = new OperListVO();
/* 219:221 */     oper.setMobileNo(moboleNo);
/* 220:222 */     List<OperListVO> operList = this.operListService.queryOperListNotLike(oper);
/* 221:223 */     if (CollectionUtils.isEmpty(operList))
/* 222:    */     {
/* 223:224 */       responseModle = new ResponseModle("error", "用户不存在。");
/* 224:225 */       return JSON.toJSONString(responseModle);
/* 225:    */     }
/* 226:227 */     JSONObject reqObj = new JSONObject();
/* 227:228 */     reqObj.put("mobileNo", moboleNo);
/* 228:229 */     reqObj.put("operation", "忘记密码修改验证码为");
/* 228:229 */     reqObj.put("merchantCode", "1201601001");
/* 229:230 */     JSONObject resObj = this.rpcMsVerifyCodeService.getCheckCode(reqObj);
/* 230:231 */     String isSucess = resObj.getString("isSuccess");
/* 231:232 */     if (!"1".equals(isSucess)) {
/* 232:233 */       responseModle = new ResponseModle("error", resObj.getString("errorMsg"));
/* 233:    */     }
/* 234:235 */     return JSON.toJSONString(responseModle);
/* 235:    */   }
/* 236:    */   
/* 237:    */   @RequestMapping(value={"/modifyPassword"}, produces={"application/json;charset=UTF-8"})
/* 238:    */   @ResponseBody
/* 239:    */   public String modifyPassword(@RequestParam("moboleNo") String moboleNo, @RequestParam("verifyCode") String verifyCode, @RequestParam("newPassword") String newPassword, @RequestParam("confirmPassword") String confirmPassword)
/* 240:    */     throws Exception
/* 241:    */   {
/* 242:253 */     boolean excuteFlag = false;
/* 243:254 */     Map<String, String> msgMap = new HashMap();
/* 244:255 */     JSONObject reqObj = new JSONObject();
/* 245:256 */     reqObj.put("mobileNo", moboleNo);
/* 246:257 */     reqObj.put("checkCode", verifyCode);
/* 247:    */     try
/* 248:    */     {
/* 249:259 */       if ((newPassword != null) && (confirmPassword != null) && (newPassword.equals(confirmPassword)))
/* 250:    */       {
/* 251:260 */         JSONObject resObj = this.rpcMsVerifyCodeService.verifyCheckCode(reqObj);
/* 252:261 */         String isSucess = resObj.getString("isSuccess");
/* 253:262 */         if ("1".equals(isSucess))
/* 254:    */         {
/* 255:263 */           OperListVO operVo = this.operListService.queryOper(moboleNo);
/* 256:264 */           if (operVo != null)
/* 257:    */           {
/* 258:265 */             operVo.setPassword(DzDigester.sha1ForOper(newPassword));
/* 259:266 */             this.operListService.updateOperList(operVo);
/* 260:267 */             excuteFlag = true;
/* 261:    */           }
/* 262:    */           else
/* 263:    */           {
/* 264:269 */             msgMap.put("errorMsg", "用户" + moboleNo + "不存在！");
/* 265:    */           }
/* 266:    */         }
/* 267:    */         else
/* 268:    */         {
/* 269:272 */           msgMap.put("errorMsg", "短信校验码不匹配");
/* 270:    */         }
/* 271:    */       }
/* 272:    */       else
/* 273:    */       {
/* 274:275 */         msgMap.put("errorMsg", "两次输入密码不致！");
/* 275:    */       }
/* 276:    */     }
/* 277:    */     catch (Exception e)
/* 278:    */     {
/* 279:278 */       LogUtil.error(e.getMessage(), e);
/* 280:279 */       msgMap.put("errorMsg", "系统发生异常");
/* 281:    */     }
/* 282:281 */     return JSON.toJSONString(assemblyResponseData(excuteFlag, msgMap));
/* 283:    */   }
/* 284:    */ }


/* Location:           F:\work\pengyu\mainServer\WEB-INF\classes\
 * Qualified Name:     tt.dz.web.controller.user.OperListController
 * JD-Core Version:    0.7.0.1
 */